package org.htmlparser.beans;

import java.awt.Dimension;
import java.awt.FontMetrics;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.Serializable;
import java.net.URLConnection;
import javax.swing.JTextArea;

public class HTMLTextBean extends JTextArea
  implements Serializable, PropertyChangeListener
{
  protected StringBean mBean;

  public HTMLTextBean()
  {
    getBean().addPropertyChangeListener(this);
  }

  public void addPropertyChangeListener(PropertyChangeListener paramPropertyChangeListener)
  {
    super.addPropertyChangeListener(paramPropertyChangeListener);
    getBean().addPropertyChangeListener(paramPropertyChangeListener);
  }

  public StringBean getBean()
  {
    if (this.mBean == null)
      this.mBean = new StringBean();
    return this.mBean;
  }

  public boolean getCollapse()
  {
    return getBean().getCollapse();
  }

  public URLConnection getConnection()
  {
    return getBean().getConnection();
  }

  public boolean getLinks()
  {
    return getBean().getLinks();
  }

  public Dimension getMinimumSize()
  {
    FontMetrics localFontMetrics = getFontMetrics(getFont());
    return new Dimension(localFontMetrics.stringWidth("Hello World"), localFontMetrics.getLeading() + localFontMetrics.getHeight() + localFontMetrics.getDescent());
  }

  public boolean getReplaceNonBreakingSpaces()
  {
    return getBean().getReplaceNonBreakingSpaces();
  }

  public String getStrings()
  {
    return getBean().getStrings();
  }

  public String getURL()
  {
    return getBean().getURL();
  }

  public void propertyChange(PropertyChangeEvent paramPropertyChangeEvent)
  {
    if (paramPropertyChangeEvent.getPropertyName().equals("strings"))
    {
      setText(getBean().getStrings());
      setCaretPosition(0);
    }
  }

  public void removePropertyChangeListener(PropertyChangeListener paramPropertyChangeListener)
  {
    super.addPropertyChangeListener(paramPropertyChangeListener);
    getBean().removePropertyChangeListener(paramPropertyChangeListener);
  }

  public void setCollapse(boolean paramBoolean)
  {
    getBean().setCollapse(paramBoolean);
  }

  public void setConnection(URLConnection paramURLConnection)
  {
    getBean().setConnection(paramURLConnection);
  }

  public void setLinks(boolean paramBoolean)
  {
    getBean().setLinks(paramBoolean);
  }

  public void setReplaceNonBreakingSpaces(boolean paramBoolean)
  {
    getBean().setReplaceNonBreakingSpaces(paramBoolean);
  }

  public void setURL(String paramString)
  {
    getBean().setURL(paramString);
  }
}